﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sofire.Data
{
    /// <summary>
    /// 表示一个实体行标识。
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class EntityRowAttribute : Attribute
    {
        /// <summary>
        /// 实体行标识的类型。
        /// </summary>
        public readonly static Type Type = typeof(EntityRowAttribute);

        private IEntityMapper _Entity;
        /// <summary>
        /// 设置或获取一个值，表示将数据行转换为实体的实现。
        /// </summary>
        public IEntityMapper Entity
        {
            get
            {
                return this._Entity;
            }
            set
            {
                this._Entity = value;
            }
        }

        private IRowMapper _Row;
        /// <summary>
        /// 设置或获取一个值，表示将实体转换为数据行的实现。
        /// </summary>
        public IRowMapper Row
        {
            get
            {
                return this._Row;
            }
            set
            {
                this._Row = value;
            }
        }

        /// <summary>
        /// 初始化 <see cref="Sofire.Data.EntityRowAttribute"/> 的新实例。
        /// </summary>
        /// <param name="entity">将数据行转换为实体的实现。</param>
        /// <param name="row">将实体转换为数据行的实现。</param>
        public EntityRowAttribute(IEntityMapper entity, IRowMapper row)
        {
            this._Entity = entity;
            this._Row = row;
        }
    }
}
